<?php

	require 'Slim/Slim.php';

	$app = new Slim();

	$app->get('/partners','getBusinessPartners');
	$app->post('/partners','addBusinessPartners');
	$app->put('/partners/:id','updateBusinessPartners');
	$app->run();

	function getBusinessPartners()
	{
		try {

			$data = file_get_contents('data.json');
		} catch (Exception $e) {
			return $e->getMessage();
			
		}
		echo $data;
		exit();
	}

	function addBusinessPartners()
	{
		$request = Slim::getInstance()->request();

		$businesspartners = $request->getBody();

		try 
		{
			if ($businesspartners) 
			{
				file_put_contents('data.json', $businesspartners);
			}
						
		} catch (Exception $e) {
			return $e->getMessage();
			
		}
		echo('Successful' . $businesspartners);
	}

	function updateBusinessPartners($id)
	{
		$request = Slim::getInstance()->request();

		$businesspartners = $request->getBody();
		
		try 
		{
			if ($businesspartners) 
			{
				file_put_contents('data.json', $businesspartners);
			}
						
		} catch (Exception $e) {
			return $e->getMessage();
			
		}
		echo('Successful' . $businesspartners);
	}
?>